package com.example.tcp.client.serde.impl;

import com.example.tcp.client.RetryTcpClient;
import com.example.tcp.client.serde.Serde;
import io.netty.buffer.Unpooled;

public class ByteBufMessageSerde implements Serde<RetryTcpClient.Message> {

    public static final ByteBufMessageSerde INSTANCE = new ByteBufMessageSerde();

    @Override
    public byte[] serialize(RetryTcpClient.Message e) {
        return e.serialize();
    }

    @Override
    public RetryTcpClient.Message deserialize(byte[] value) {
        return new RetryTcpClient.ByteBufMessage(Unpooled.copiedBuffer(value));
    }
}
